package cn.cdnsu.org.service.impl;

import cn.cdnsu.base.service.impl.IBaseServiceImpl;
import cn.cdnsu.org.domain.Employee;
import cn.cdnsu.org.dto.EmployeeDTO;
import cn.cdnsu.org.mapper.EmployeeMapper;
import cn.cdnsu.org.service.IEmployeeServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class EmployeeServiceImplI extends IBaseServiceImpl<Employee> implements IEmployeeServiceI {

    @Autowired
    private EmployeeMapper mapper;

    @Override
    public Employee selectOneById(Long id) {
        return mapper.selectOneById(id);
    }

    @Override
    public Employee selectByName(String name) {
        return mapper.selectByName(name);
    }

    @Override
    public List<Long> selectByEmployeeId(Long id) {
        return mapper.selectByEmployeeId(id);
    }

    @Override
    public void insertByEmployeeId(EmployeeDTO employeeDTO) {
        //删除该员工的角色
        mapper.deleteByEmployeeId(employeeDTO.getId());
        //保存角色
        mapper.inserByEmployeeId(employeeDTO);
    }

    @Override
    public List<String> queryPermissionByUserId(Long id) {
        return mapper.queryPermissionByUserId(id);
    }


}
